package com.googlecode.grs.event;

import com.googlecode.grs.core.Event;
import com.googlecode.grs.sensor.RangeFinder;

/**
 * RangeFinderEvent holds relevant ranging data including angular position
 * 
 * @author ajc
 * 
 */
public class RangeFinderEvent implements Event {

	private final RangeFinder sensor;
	private final double oldDistance;
	private final double newDistance;
	private final double angle; // units? wrt heading? absolute?
	private final double heading; // heading at time of event

	/**
	 * 
	 * @param sensor
	 * @param oldDistance
	 * @param newDistance
	 * @param angle
	 * @param heading
	 */
	public RangeFinderEvent(RangeFinder sensor, double oldDistance,
			double newDistance, double angle, double heading) {
		this.sensor = sensor;
		this.oldDistance = oldDistance;
		this.newDistance = newDistance;
		this.angle = angle;
		this.heading = heading;

	}

	/**
	 * Source rangefinder which sent this event
	 * 
	 * @return
	 */
	public RangeFinder getSource() {
		return sensor;
	}

	/**
	 * Original distance before this event
	 * 
	 * @return
	 */
	public double getOriginalDistance() {
		return oldDistance;
	}

	/**
	 * The distance that this sensor changed to at the time of this event
	 * 
	 * @return
	 */
	public double getFinalDistance() {
		return newDistance;
	}

	/**
	 * RelativeAngle is the angle of the sensor with respect to the robot.
	 * 
	 * @return
	 */
	public double getRelativeAngle() {
		return angle;
	}

	/**
	 * Robot heading is the absolute angular position of the robot in the
	 * environment
	 * 
	 * @return
	 */
	public double getRobotHeading() {
		return heading;
	}

	/**
	 * Sensor heading is the absolute angular position of the sensor in the
	 * environment
	 * 
	 * @return
	 */
	public double getSensorHeading() {
		return angle + heading;
	}

}
